public abstract class Car{
    //提供类的初始化块
    static{
        System.out.println("读入汽车系统……");
    }
    {
        System.out.println("汽车启动……");
    }
    private int turnrate;//每分钟转的次数
    private double radius;//轮子半径
    private double usetime;//使用时间
    private int passange;//乘客数

    public void Car(int turnrate, double radius, double usetime, int passanger){
        this.turnrate = turnrate;
        this.radius = radius;
        this.usetime = usetime;
        this.passange = passanger;
    }

    //setter&getter
    public void setTurnrate(int inputt) {
        turnrate = inputt;
    }
    public int getTurnrate() {
        return turnrate;
    }
    public void setRadius(double inputr) {
        radius = inputr;
    }
    public double getRadius() {
        return radius;
    }
    public void setUsetime(double inputu) {
        usetime = inputu;
    }
    public double getUsetime() {
        return usetime;
    }
    public void setPassanger(int inputp) {
        passange = inputp;
    }
    public int getPassanger() {
        return passange;
    }

    //汽车里程数(车类提供的通用方法)
    //计算车轮周长
    public double calGirth() {
        return 2 * Math.PI * radius *0.0001;
    }
    //计算车速
    public double getSpeed() {
       return calGirth() * turnrate; 
    }
    
    public double getDistance(){
        return this.calGirth() *usetime;
    }

    //汽车功能描述（车类留给子类自己实现的抽象方法）
    public abstract void getFuntion();

    //汽车性能描述（车类为子类提供的性能描述模板，由子类重写之后再自己使用）
    public void getValue() {
        //车速
        System.out.println("[车速] " +String.format("%.2f",this.getSpeed() ) +"km/h");
        //限载乘客
        System.out.println("[乘客数] " +this.getPassanger() +"位");
        //里程数
        System.out.println("[里程数]" + String.format("%.2f", this.getDistance())+ "公里");

    }

    //安全提示
    public abstract void warnSafe();

    //选择车型
    public int chooseType(Car car) {
        if(car instanceof LittleCar){
            return 0;
        }
        else if(car instanceof Truck){
            return 1;
        }
        else if(car instanceof Motorbike){
            return 2;
        }
        else
        return -1;        
    }


}